package cn.amsser.myshowcase.arithmetic.sort;

public class QuickSort {

	public void sort(int[] array, int left, int right) {

		int temp = array[left];
		int middle = array[(left + right) / 2];
		int i = left + 1;
		int j = right;
		
		do{
			while(middle > array[i]){
				i++;
			}
			while(middle < array[j]){
				j--;
			}
			
			if(i<=j){
				temp = array[i];
				array[i] = array[j];
				array[j] = temp;
			}
			
		}while(i<j);
		
		sort(array,left,middle-1);
		sort(array,middle+1,right);
		
	}

}
